package com.huike.web.controller.rule;

import com.huike.clues.domain.TbRulePool;

import com.huike.clues.service.TbRulePoolService;
import com.huike.common.annotation.Log;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description 线索或商机池规则相关接口
 * @Author ggzhuqiang
 * @Date 2023-07-11 21:17
 */

@Slf4j
@Api("线索或商机池规则相关接口")
@RestController
@RequestMapping("/rule/pool")
public class RulePoolController {



    @Resource
    private TbRulePoolService tbRulePoolService;

    /**
     * 修改线索池规则
     * @param tbRulePool
     * @return
     */
    @ApiOperation("修改线索池规则")
    @PutMapping
    public AjaxResult updateCluesRule(@RequestBody TbRulePool tbRulePool){
        log.info("修改线索池规则:{}",tbRulePool);
        tbRulePoolService.updateTbRulePool(tbRulePool);
        return AjaxResult.success();
    }


    @ApiOperation("获取规则基础信息type=0 线索 type=1 商机")
    @GetMapping("/{type}")
    public AjaxResult getRuleByType(@PathVariable String type){
        log.info("获取规则基础信息type=0 线索 type=1 商机:{}",type);
        TbRulePool tbRulePool = tbRulePoolService.selectTbRulePoolByType(type);
        return AjaxResult.success(tbRulePool);
    }


    /**
     * 新增线索池规则
     */
    //@ApiOperation("新增线索池规则")
    //@PreAuthorize("@ss.hasPermi('clues:pool:add')")
    @Log(title = "线索池规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbRulePool tbRulePool)
    {
        return AjaxResult.success(tbRulePoolService.insertTbRulePool(tbRulePool));
    }




}
